
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" type="text/css" href="css/reset.css">
    <link rel="stylesheet" type="text/css" href="css/layer.css">
    <link rel="stylesheet" type="text/css" href="css/swiper.min.css">
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" type="text/css" href="css/index.css">
    <script src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.cookie.js"></script>
    <script src="js/layer.js"></script>
    <script src="js/swiper.min.js"></script>
    <!-- <link href="css/video-js.min.css" rel="stylesheet"> -->
    <script type="text/javascript" src="js/common.js"></script>
    <style type="text/css">
    	.video-js{
    		width:100% !important;
    		height:100% !important;
    		position:absolute;
    		left:0 !important;
    	}
    	#mediaplayer{
    		height: 100%;
		    position: absolute;
		    left:0;
		    top:0;
    	}
    	#my-video{
    		display:none;
    	}
        #mediaplayer_logo{
       	   display:none;
        }
    </style>
</head>
<body>
    <div class="m">
      <!-- <video src="" id="my-video" class="video-js" controls preload="auto" width="100%" height="100%"
		  poster="">
      </video> -->
      <div id="mediaplayer"></div>
    </div>
    <script src="jwplayer_files/jwplayer.js"></script>
	<script src="jwplayer_files/jwpsrv.js"></script>
	<script type="text/javascript"></script>
	<script type="text/javascript">
		$(function(){
			var url = window.location.href;
			function getQueryString(name) {
		        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		        var r = window.location.search.substr(1).match(reg);
		        if (r != null) return (r[2]);
		        return null;
		    }
	        var id = getQueryString('id');
	        var uid = $.cookie('id');
	        var token = $.cookie('token_access');
	        if($.cookie('token_access') == undefined){
				window.location.href="login.html";
			}else{
		        $.ajax({
					url: window.baseUrl+'api/movie/details',
					type: 'get',
					data:{
						id : id,
					},
					beforeSend: function (XMLHttpRequest) {
		         		XMLHttpRequest.setRequestHeader("token", $.cookie('token_access'));
		            },
					success: function (data) {
					  	var details = '';
					  	var data = data.datas;
					  	if(data.url == ''){
					  		window.location.href="detail.html?id="+id;
					  	}else{
					  		function IsPC() {
							    var userAgentInfo = navigator.userAgent;
							    var Agents = ["Android", "iPhone",
							                "SymbianOS", "Windows Phone",
							                "iPad", "iPod"];
							    var flag = true;
							    for (var v = 0; v < Agents.length; v++) {
							        if (userAgentInfo.indexOf(Agents[v]) > 0) {
							            flag = false;
							            break;
							        }
							    }
							    return flag;
							}
							var flag = IsPC(); 
							// if(flag == true){
								jwplayer('mediaplayer').setup({
								    'flashplayer': 'jwplayer/jwplayer.flash.swf',
									'image': data.image,
								    'width': '100%',
									'aspectratio':'16:9',
								    'file': data.url,
								    'autoplay':'true'
								});
							// }else{
							// 	$("#my-video").show();
							// 	$("#my-video").attr('src',data.url)
					        // 	$("#my-video").attr('poster',data.image)
					        // 	document.getElementById('my-video').play();
							// }
					  		$("title").html(data.movieName)
					  		
					  	}
					}
				});
		    }
		    $.ajax({
				url: window.baseUrl+'api/movie/addViewHistory',
				type: 'get',
				data:{
					movieId : id,
				},
				beforeSend: function (XMLHttpRequest) {
	         		XMLHttpRequest.setRequestHeader("token", $.cookie('token_access'));
	            },
				success: function (data) {
				}
	        });
		})
	</script>
</body>
</html>